package com.wolf.exception;

public enum ETL_ERROR_MSG {
    ERROR_UPLOAD_001("UPLOAD", "001", "Root directory is not found."),
    ERROR_UPLOAD_002("UPLOAD", "002", "Directory is not found."),
    ERROR_UPLOAD_003("UPLOAD", "003", "File is not found."),
    ERROR_UPLOAD_004("UPLOAD", "004", "Read file exception."),

    ERROR_SYSTEM_001("SYSTEM", "001", "Classname[%s] could not find the corresponding class."),
    ERROR_SYSTEM_002("SYSTEM", "002", "FieldType could not primitive."),
    ERROR_SYSTEM_003("SYSTEM", "003", "SQL GUID is empty."),

    ERROR_SQL_SEARCH_001("SQL_SEARCH", "001", "需要设置WHERE条件."),
    ERROR_SQL_SEARCH_002("SQL_SEARCH", "002", "查询异常."),
    ERROR_SQL_SEARCH_003("SQL_SEARCH", "003", "查询参数异常."),
    ERROR_SQL_SEARCH_004("SQL_SEARCH","004","新增SQL必须以insert 开头"),
    ERROR_SQL_SEARCH_005("SQL_SEARCH","005","修改SQL必须以update 开头"),
    ERROR_SQL_SEARCH_006("SQL_SEARCH","006","删除SQL必须以delete 开头"),
    ERROR_SQL_SEARCH_007("SQL_SEARCH","007","查询SQL必须以select 开头"),

    ERROR_FILE_001("FILE", "001", "路径为空."),
    ERROR_FILE_002("FILE", "002", "文件名称不是以.properties结尾."),
    ERROR_FILE_003("FILE", "003", "文件读取异常."),
    ERROR_FILE_004("FILE", "004", "文件路径或GUID为空.."),

    ERROR_STRING_001("STRING", "003", "字符串为空."),

    ERROR_RESULT_001("RESULT", "001", "操作失败."),

    ERROR_ELEMENT_001("ELEMENT","001","type 类型为空"),
    ERROR_ELEMENT_002("ELEMENT","002","json 数据为空"),
    ERROR_ELEMENT_003("ELEMENT","003","数据为空"),

    ERROR_TRANSFORM_RULE_001("TRANSFORM_RULE","001","不符合检查规则"),
    ERROR_TRANSFORM_RULE_002("TRANSFORM_RULE","002","函数参数有误"),
    ERROR_TRANSFORM_RULE_003("TRANSFORM_RULE","003","找不到函数"),
    ERROR_TRANSFORM_RULE_004("TRANSFORM_RULE","004","表关联字段类型不一致"),
    ERROR_TRANSFORM_RULE_005("TRANSFORM_RULE","005","js语法错误"),
    ERROR_TRANSFORM_RULE_006("TRANSFORM_RULE","006","不是json对象"),
    ERROR_TRANSFORM_RULE_007("TRANSFORM_RULE","007","找不到api"),
    ERROR_TRANSFORM_RULE_008("TRANSFORM_RULE","008","找不到javascript"),
    ERROR_TRANSFORM_RULE_009("TRANSFORM_RULE","009","找不到ETL定义");



    private String type;
    private String code;
    private String name;

    ETL_ERROR_MSG(String type, String code, String name) {
        this.type = type;
        this.code = code;
        this.name = name;
    }

    public String getErrorMessage(Object... args) {
        if (!(args == null || args.length == 0)) {
            this.name = String.format(this.name, args);
        }
        return String.format("System exception: %s-%s:%s", this.type, this.code, this.name);
    }
}
